#include <iostream>
#include <fstream>
#include <ctime>
#include <vector>
using namespace std;
vector<int>bubs (vector<int>s1){
  for(int i = 0;i<s1.size();i++){
    int k = 0;
    for(int j = 0;j<s1.size() - 1 - i;j++){
      if (s1[j] > s1[j+1]){
        int t = s1[j];
        s1[j] = s1[j+1];
        s1[j+1] = t;
        k++;
      }
    }
    if (k == 0){
      break;
    }
  }
  return s1;
}
int main(){
  ifstream h;
  h.open("m1_sorted.txt");
  vector<int>s1;
  int a;
  while(h >> a){
    s1.push_back(a);
  }
  double st = clock();
  s1 = bubs(s1);
  double end =  clock();
  cout<<"m1_sorted "<<(end - st) / 1000<< " "<<"milliseconds"<<endl;
  ifstream h1;
  h1.open("m2_reverse.txt");
  vector<int>s2;
  int a1;
  while(h1 >> a1){
    s2.push_back(a1);
  }
  double st1 = clock();
  s2 = bubs(s2);
  double end1 =  clock();
  cout<<"m2_reverse "<<(end1 - st1) / 1000<< " "<<"milliseconds"<<endl;
  ifstream h2;
  h2.open("m3_shuffle.txt");
  vector<int>s3;
  int a2;
  while(h2 >> a2){
    s3.push_back(a2);
  }
  double st2 = clock();
  s2 = bubs(s2);
  double end2 =  clock();
  cout<<"m3_shuffle "<<(end2 - st2) / 1000<< " "<<"milliseconds"<<endl;
}
